using System.Text.RegularExpressions;

namespace Ioc.Kernel
{
    public class Parameter {
        public string Name { get; set; }
        public string Value { get; set; }
        public string EscapedValue { get; set; }

        /// <summary>
        /// Determines whether [is component reference].
        /// </summary>
        /// <returns>
        /// 	<c>true</c> if [is component reference]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsComponentReference()
        {
            var match = Regex.Match(Value,@"\${(.+)}");
            if(match.Success)
                EscapedValue = match.Groups[1].Value;
            return match.Success;
        }

        /// <summary>
        /// Determines whether [is setter parameter].
        /// </summary>
        /// <returns>
        /// 	<c>true</c> if [is setter parameter]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsSetterParameter()
        {
            var match = Regex.Match(Value, @"\#{(.+)}");
            if (match.Success)
                EscapedValue = match.Groups[1].Value;
            return match.Success;
        }
    }
}